package com.jwds.digital.bios.business.api.controller.basic;

import com.jwds.digital.bios.business.core.infrastructure.dto.basic.BasicOperateLogReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltAnomalyInfoReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.basic.BasicOperateLogRespVO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltAnomalyInfoRespVO;
import com.jwds.digital.bios.business.service.service.basic.IBasicOperateLogService;
import com.jwds.tdc.framework.application.lib.BaseResponse;
import com.jwds.tdc.framework.application.lib.page.PageRequest;
import com.jwds.tdc.framework.application.lib.page.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Description BasicOperateLogController
 * @Author xiao  xun
 * @Date 2024-12-07
 */
@Slf4j
@Api(tags = "操作日志信息")
@RestController
@RequestMapping("/basic/operate/log")
public class BasicOperateLogController {
    @Resource
    private IBasicOperateLogService service;

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询")
    public BaseResponse<BasicOperateLogRespVO> queryById(@PathVariable("id") Long id) {
        BasicOperateLogRespVO respVo = service.queryById(id);
        return BaseResponse.success(respVo);
    }
    /**
     * 分页查询
     * @param pageRequest 分页查询参数
     * @return pageResponse 分页查询结果
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "分页查询")
    public BaseResponse<PageResponse<BasicOperateLogRespVO>> page(@Valid @RequestBody PageRequest<BasicOperateLogReqDTO> pageRequest) {
        PageResponse<BasicOperateLogRespVO> respVoPage = service.page(pageRequest);
        return BaseResponse.success(respVoPage);
    }


    /**
     * 列表查询
     * @param reqDto 查询条件
     * @return respVOList 查询结果
     */
    @PostMapping("/all")
    @ApiOperation(value = "列表查询")
    public BaseResponse<List<BasicOperateLogRespVO>> list(@Valid @RequestBody BasicOperateLogReqDTO reqDto) {
        List<BasicOperateLogRespVO> respVoList = service.list(reqDto);
        return BaseResponse.success(respVoList);
    }

    @PutMapping("/")
    @ApiOperation(value = "更新对象")
    public BaseResponse<?> update(@Validated @RequestBody BasicOperateLogReqDTO reqDto) {
        service.update(reqDto);
        return BaseResponse.success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除对象")
    public BaseResponse<?> delete(@PathVariable("id") Long id) {
        service.delete(id);
        return BaseResponse.success();
    }
}
